#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
#include<cmath>
#include<map>
#include<set>
#include<cstdio>
#include<algorithm>
#define debug(a) cout<<#a<<"="<<a<<endl;
using namespace std;
const int maxn=2e5+1000;
typedef long long LL;
inline LL read(){LL x=0,f=1;char ch=getchar();	while (!isdigit(ch)){if (ch=='-') f=-1;ch=getchar();}while (isdigit(ch)){x=x*10+ch-48;ch=getchar();}
return x*f;}
LL dp[maxn][2];
char a[maxn];
int main(void){
   	cin.tie(0);std::ios::sync_with_stdio(false);
    LL t;cin>>t;
    while(t--){
        cin>>(a+1);LL n=strlen(a+1);
        LL ans=0;
        for(LL i=1;i<=n;i++){
            for(LL j=0;j<2;j++) dp[i][j]=0;
        }
        for(LL i=1;i<=n;i++){
            if(a[i]=='0'){
                dp[i][0]=max(1LL,dp[i-1][1]+1);
            }
            if(a[i]=='1'){
                dp[i][1]=max(1LL,dp[i-1][0]+1);
            }
            if(a[i]=='?'){
                dp[i][1]=max(1LL,dp[i-1][0]+1);
                dp[i][0]=max(1LL,dp[i-1][1]+1);
            }
            ans+=max(dp[i][0],dp[i][1]);
       }
       cout<<ans<<"\n";
    }
   	return 0;
}
